package com.note.services.controller;

import com.note.common.domain.File;
import com.note.config.constants.GatewayConstants;
import com.note.services.service.FileService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.constraints.NotBlank;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Package：com.note.services.controller
 * @Name：FileController
 * @Author：热伊木
 * @Email：uyevan@163.com
 * @Date：2024-05-02-9:33
 * @Description：笔记文件上传记录控制层
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/services")

public class FileController {

    @Autowired
    private FileService fileService;

    @PostMapping("/internal/recordUploadNoteFile")
    @Operation(summary = "recordUploadNoteFile", description = "笔记文件上传后记录")
    public void recordUploadNoteFile(@RequestParam @NotBlank(message = "internalKey not null.") String internalKey, File file) {
        if (internalKey.equals(GatewayConstants.INTERNAL_KEY)) {
            fileService.recordUpload(file);
        }
    }
}
